class Connon extends Sprite {
  constructor(type) {
    if(type > 7 || type < 1){
      throw new Error('炮筒的类型不对，范围为1到7。');
    }

    let connonData = __g_resources.cannon[`cannon${type}`];
    super({
      image:      connonData.image,
      sx:         connonData.frame.x,
      sy:         connonData.frame.y,
      w:          connonData.frame.w,
      h:          connonData.frame.h,
      x:          442,
      y:          572,   //暂定是这里
      max_frame:  5,
      max_tick:   5
    });
    this.type = type;
    this.energy = 2140;  //默认炮筒的能量为2140，原因能量柱的长度为214px*10
  }

  setType(newType){
    if(newType > 7 || newType < 1){
      throw new Error('炮筒的类型不对，范围为1到7。');
    }
    let data = __g_resources.cannon[`cannon${newType}`];
    this.image  =  data.image;
    this.sx     =  data.frame.x;
    this.sy     =  data.frame.y;
    this.w      =  data.frame.w;
    this.h      =  data.frame.h;
    this.type=newType;
  }
}
